<!--
 * Created by PhpStorm.
 * User: jackhhy
 * Date: 2019/7/4-11:09
 * Link: https://gitee.com/luckygyl/luckyAdmin
 * FileName: my_info.html
 *-->

{include file="public/head" /}

<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">设置我的资料</div>
                <div class="layui-card-body" >

                    <div class="layui-form" lay-filter="">

                        <div class="layui-form-item">
                            <label class="layui-form-label">所属角色：</label>
                            <div class="layui-input-inline">
                                <select name="role_id" lay-verify="required" >
                                    {volist name="tree" id="t"}
                                    <option value="{$t.id}"  {eq name="$admin_info.role_id" value="$t.id"} selected {/eq}>{$t.title_show}</option>
                                    {/volist}
                                </select>
                            </div>
                            <div class="layui-form-mid layui-word-aux">管理员所属的角色</div>
                            <input type="hidden" name="id"  value="{$admin_info.id}">
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">用户名：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" lay-verify="required" value="{$admin_info.username}"  class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">一般用于后台登入名</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">昵称：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="nickname" value="{$admin_info.nickname}" lay-verify="required" autocomplete="off" placeholder="请输入昵称" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">管理员昵称用于后台显示</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">性别：</label>
                            <div class="layui-input-block">
                                <input type="radio" name="sex" value="男" {eq name="$admin_info.sex" value="男" }  checked {/eq} title="男">
                                <input type="radio" name="sex" value="女" {eq name="$admin_info.sex" value="女" }  checked {/eq} title="女" >
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">头像：</label>
                            <div class="layui-input-inline">
                                <input name="avatar" lay-verify="required" id="LAY_avatarSrc" readonly placeholder="图片地址" value="{$admin_info.avatar}" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary" id="LAY_avatarUpload">
                                    <i class="layui-icon">&#xe67c;</i>上传头像
                                </button>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">头像显示：</label>
                            <div class="layui-input-inline">
                                <div class="layui-upload">
                                    <div class="layui-upload-list">
                                        <img class="layui-upload-img" style="width: 200px;height: auto;" src="{$admin_info.avatar}" id="demo1">
                                    </div>
                                </div>
                            </div>
                        </div>
                        {:token()}
                        <div class="layui-form-item">
                            <label class="layui-form-label">手机号码：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="phone" value="{$admin_info.phone}" lay-verify="required|phone" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">邮箱：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="email" value="{$admin_info.email}"  autocomplete="off" class="layui-input">
                            </div>
                        </div>


                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">备注：</label>
                            <div class="layui-input-block">
                                <textarea name="beizhu" placeholder="请输入内容" class="layui-textarea">{$admin_info.beizhu}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="setmyinfo">确认修改</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>


{include file="public/js" /}

<script >

    layui.use(['element','form', 'jquery', 'laydate','util','upload'], function () {
        var element = layui.element;
        var form = layui.form;
        var $ = layui.jquery;
        var laydate = layui.laydate;
        var util=layui.util;
        var upload=layui.upload;

        form.render();

        /**
         * 表格提交
         */
        form.on('submit(setmyinfo)', function (data) {
            FormSubmit("{:url('setting/MyInfo')}",data.field);
            return false;
        });




        //图片上传
        upload.render({
            elem:'#LAY_avatarUpload'
            ,url: "{:url('admin/common/UpThumbImg')}" //头像上传地址
            ,accept: 'images' //
            ,acceptMime: 'image/*'
            ,size: 1024*9
            //,data:{width:400,height:600}
            ,before:function (res) {
                loading = layer.load(2, {
                    shade: [0.2, '#000'] //0.2透明度的白色背景
                });
            }
            ,done: function(data){
                layer.close(loading);
                if (data.code==1){
                    layer.msg(data.msg, {icon: 1, time: 1000},function () {
                        $("#demo1").attr("src",data.path);
                        $("#LAY_avatarSrc").val(data.path);
                    });
                } else {
                    layer.msg(data.msg, {icon: 5, time: 1000});
                }
            }
            ,error:function (red) {
                layer.close(loading);
                layer.msg("网络错误", {icon: 5, time: 1500});
            }
        });





    });

</script >

</body >
</html >